%load_ext autoreload
%autoreload 2
from pipeline import get_maps
from helpers import load_image, load_image2
import matplotlib.pyplot as plt
#%autoreload 2
%matplotlib inline
#Datastructure
from collections import OrderedDict
DATA_PATH = '../data/'
def show_maps(image1_path, image2_path, K, square=True):
if(square):
img_content = load_image(DATA_PATH + image1_path)
img_context = load_image(DATA_PATH + image2_path)
else:
img_content = load_image2(DATA_PATH + image1_path, width=224)
img_context = load_image2(DATA_PATH + image2_path, width=224)
dicto = get_maps(img_content, img_context, K)
plt.figure(figsize=(15, 10))
plt.subplot(2, 2, 1)
plt.imshow(img_content)
plt.subplot(2, 2, 2)
plt.imshow(img_context)
plt.gcf().text(0.05, 0.7, "Original ", fontsize=25)
for key, values in dicto.items():
Ws, Hs = values
for i in range(0,K):
plt.figure(figsize=(15, 10))
plt.gcf().text(0.05, 0.7, "K = " + str(i+1), fontsize=30)
plt.gcf().text(0.885, 0.7, key.replace('conv',''), fontsize=30)
plt.subplot(2, 2, 1)
plt.imshow(Ws[:,:,i])
#plt.colorbar()
plt.subplot(2, 2, 2)
plt.imshow(Hs[i])
#plt.colorbar()
plt.show()
image1_path='../data/face/1.jpg'
image2_path='../data/face/2.jpg'
K = 10
show_maps(image1_path, image2_path, K)
show_maps(image1_path, image2_path, K)
[show_maps(image1_path, image2_path, K) for K in map(lambda x: x*5, list(range(1,6)))]
image1_path='../data/face/1.jpg'
image2_path='../data/face/2.jpg'
image3_path='../data/face/3.jpg'
image4_path='../data/face/4.jpg'
image5_path='../data/face/5.jpg'
#let's check two males
show_maps(image3_path, image5_path, 20)
show_maps(image4_path, image5_path, 20)
show_maps(image2_path, image5_path, 20)
image_path_paint1 = '../data/face_paintings/4.jpg'
show_maps(image3_path, image_path_paint1, 20)
image_path_paint_face_7 = '../data/face_paintings/7.jpg'
show_maps(image2_path, image_path_paint_face_7, 20)
show_maps('../data/city/1.jpg', '../data/city/7.jpg', 20)
show_maps('../data/city/2.jpg', '../data/city/4.jpg', 20)
show_maps('../data/city/5.jpg', '../data/city/7.jpg', 20)
#no water map because of light reflect maybe?
show_maps('../data/indoor/1.jpg', '../data/indoor/2.jpg', 20)
show_maps('../data/indoor/4.jpg', '../data/indoor/6.jpg', 20)
# K = 10 is interesting
show_maps('../data/landscape/4.jpg', '../data/landscape/5.jpg', 20, True)
show_maps('../data/landscape/3.jpg', '../data/landscape/4.jpg', 20, True)
show_maps('../data/landscape/1.jpg', '../data/landscape/5.jpg', 20, True)
# this setup doesn't work so well for landscape i think
show_maps('../data/landscape/5.jpg', '../data/landscape_paintings/2.jpg', 20, True)